/* eslint-disable no-param-reassign */
import { createSelector, createSlice, PayloadAction } from '@reduxjs/toolkit';
import { ReduxState } from '..';
import { TimerModel } from '@/pages/schedule/type';

export type ScheduleStateList = {
  timerList: TimerModel[];
};

/**
 * Slice
 */
const scheduleStateSlice = createSlice({
  name: 'uiState',
  initialState: {
    timerList: [], // 初始化 timerList 为一个空数组，或者根据需要设置默认值
  } as ScheduleStateList,
  reducers: {
    updateTimerList(state, action: PayloadAction<ScheduleStateList['timerList']>) {
      state.timerList = action.payload;
    },
  },
});

/**
 * Actions
 */
export const { updateTimerList } = scheduleStateSlice.actions;


export const selectTimerList = (state: ReduxState) => state.scheduleState.timerList;
/**
 * Reducer
 */
export default scheduleStateSlice.reducer;
